import { RouteRecordRaw, createRouter, createWebHashHistory } from "vue-router";
import i18n from "@/lang/index";
import c2cChildren from "./c2c";
import personChildren from "./person";
const { t }	= i18n.global; 
export const Layout = () => import("@/layout/index.vue");

export const constantRoutes: RouteRecordRaw[] = [
  // {
  //   path: "/redirect",
  //   component: Layout,
  //   meta: { hidden: true },
  //   children: [
  //     {
  //       path: "/redirect/:path(.*)",
  //       component: () => import("@/views/redirect/index.vue"),
  //     },
  //   ],
  // },
  // {
  //   path: "/login",
  //   component: () => import("@/views/login/index.vue"),
  // },
  {
    path: "/",
    component: Layout,
    redirect: "/home",
	meta:{
		hidden:true
	},
		// 首页
    children: [
			{
				path: "home",
				component: () => import("@/views/home/index.vue"),
				name: "Home",
				meta: { 
					title: "dashboard", 
					icon: "homepage", 
					hidden: true 
				}
			},
			// 新闻页
			{
				path:"news",
				component: () => import("@/views/news/index.vue"),
				name: "News",
				meta: { 
					title: "navbar.news", 
					icon: "news", 
					affix: true,
					hidden: true 
				},
				children:[
					{
						path:":id",
						component: () => import("@/views/news/newsdetail/index.vue"),
						name: "NewsDetail",
					}
				]
			},
			// 消息页
			{
				path:"message",
				component: () => import("@/views/message/index.vue"),
				name: "Message",
				meta: { 
					title: "navbar.message", 
					icon: "message", 
					affix: true,
					hidden: true 
				},
			},
			// 数字货币充值
			{
				path:"digitalCurrency",
				component: () => import("@/views/digital/index.vue"),
				name: "DigitalCurrency",
				meta: { 
					title: "navbar.message", 
					icon: "message", 
					affix: true,
					hidden: true 
				},
			},
			// 登录
			{
				path:"login",
				component: () => import("@/views/login/index.vue"),
				name: "Login",
				meta:{
					hidden: true
				}
			},
			// 重置密码
			{
				path:"reset",
				component: () => import("@/views/login/resetPassword/index.vue"),
				name: "Reset",
				meta:{
					hidden: true
				}
			},
			// 注册
			{
				path:"register",
				component: () => import("@/views/register/index.vue"),
				name: "Register",
				meta:{
					hidden: true
				}
			},
			// 身份认证页
			{
				path:"authentication",
				component: () => import("@/views/authentication/index.vue"),
				name: "Authentication",
				meta:{
					hidden: true
				}
			},
			// 一键买币
			{
				path:"purchase",
				component: () => import("@/views/purchase/index.vue"),
				name: "Purchase",
				redirect: "/transaction/c2c/quick",
				meta:{
					hidden: false,
					title:"navbar.purchase"
				}
			},
			// 行情
			{
				path:"market",
				component: () => import("@/views/market/index.vue"),
				name: "Market",
				meta:{
					hidden: false,
					title:"navbar.market"
				}
			},
			// 交易
			{
				path:"transaction",
				component: () => import("@/views/redirect/index.vue"),
				name: "Transaction",
				meta:{
					hidden: false,
					title:"navbar.transaction"
				},
				children:[
					// 闪兑
					{
						path:"exchange",
						component: () => import("@/views/transaction/exchange/index.vue"),
						name: "Exchange",
						meta:{
							hidden: false,
							title:"navbar.exchange.title",
							icon:"/header/exchange.svg",
							content:"navbar.exchange.content"
						}
					},
					// C2C
					{
						path:"c2c",
						component: () => import("@/views/transaction/c2c/index.vue"),
						name: "C2c",
						redirect: "/transaction/c2c/quick",
						meta:{
							hidden: false,
							title:"navbar.c2c.title",
							icon:"/header/c2c.svg",
							content:"navbar.c2c.content"
						},
						children:[
							...c2cChildren
						]
					},
					// 现货交易
					{
						path:"spot",
						component: () => import("@/views/transaction/spot/index.vue"),
						name: "Spot",
						meta:{
							hidden: false,
							title:"navbar.spot.title",
							content:"navbar.spot.content",
							icon:"/header/spot.svg"
						}
					}
				]
			},
			// 合约
			{
				path:"contract",
				component: () => import("@/views/contract/index.vue"),
				name: "Contract",
				meta:{
					hidden: false,
					title:"navbar.contract"
				}
			},
			// 理财
			{
				path:"financing",
				component: () => import("@/views/financing/index.vue"),
				name: "Financing",
				meta:{
					hidden: false,
					title:"navbar.financing"
				},
				children:[
					// 理财产品
					{
						path:"products",
						component: () => import("@/views/financing/products/index.vue"),
						name: "Products",
						meta:{
							hidden: false,
							title:"navbar.products.title",
							icon:"/header/products.svg",
							content:"navbar.products.content",
						}
					},
					//定期
					{
						path:"regular",
						component: () => import("@/views/financing/regular/index.vue"),
						name: "Regular",
						meta:{
							hidden: false,
							title:"navbar.regular.title",
							icon:"/header/regular.svg",
							content:"navbar.regular.content",
						}
					}
				]
			},
			// 更多
			{
				path:"more",
				component: () => import("@/views/redirect/index.vue"),
				name: "More",
				redirect: "/more/payment",
				meta:{
					hidden: false,
					title:"navbar.more"
				},
				children:[
					// 支付
					{
						path:"payment",
						component: () => import("@/views/more/payment/index.vue"),
						name: "Payment",
						meta:{
							hidden: false,
							title:"navbar.payment.title",
							icon:"/header/payment.svg",
							content:"navbar.payment.content",
						}
					},
					// 转账
					{
						path:"transfer",
						component: () => import("@/views/more/transfer/index.vue"),
						name: "Transfer",
						meta:{
							hidden: true,
							title:"navbar.payment.title",
							icon:"/header/payment.svg",
							content:"navbar.payment.content",
						}
					},
					// 收款
					{
						path:"receive",
						component: () => import("@/views/more/receive/index.vue"),
						name: "Receive",
						meta:{
							hidden: true,
							title:"navbar.payment.title",
							icon:"/header/payment.svg",
							content:"navbar.payment.content",
						}
					},
					// 转账成功
					{
						path:"transferResult",
						component: () => import("@/views/more/transferResult/index.vue"),
						name: "TransferResult",
						meta:{
							hidden: true,
							title:"navbar.payment.title",
							icon:"/header/payment.svg",
							content:"navbar.payment.content",
						}
					}
				]
			},
			// 个人账户
			{
				path:"person",
				component: () => import("@/views/person/index.vue"),
				name: "Person",
				redirect: "/person/overview",
				meta:{
					hidden: true,
					title:"navbar.more"
				},
				children:[
					...personChildren
				]
			}
    ],
  },
];

// 创建路由
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes as RouteRecordRaw[],
  scrollBehavior: () => ({ left: 0, top: 0 }),
});

// 重置路由
export function resetRouter() {
  router.replace({ path: "/login" });
  location.reload;
}

export default router;
